#pragma once

// Convert Time From Hours, Minutes, Seconds, Milliseconds To Milliseconds
void ConvertTimeToMilliseconds(long& hours, long& minutes, long& seconds, long& milliseconds);
// Convert Time From Milliseconds To Hours, Minutes, Seconds, Milliseconds
void ConvertTimeFromMilliseconds(long& hours, long& minutes, long& seconds, long& milliseconds);

// Get Time In Milliseconds
long GetTimeInMilliseconds(const long hours, const long minutes, const long seconds, const long milliseconds);

// Get The Digit From A Number
template <class T>
inline T GetDigitFromNumber(const T number, int position) 
{
    return ( position == 0 ) ? number % 10 : GetDigitFromNumber( number / 10, -- position );
}

// Calculate Number Of Digits
// Does Not Calculate Decimal Points
// Does Not Work If T Is A Float/Double ( Basically Decimal Points )
template <class T>
inline int CalculateNumberOfDigits(const T number)
{
	// How Many Digits There Are
	int count = 0;
	// The Number
	T theNumber = number;

	// As Long As The Number Is Larger Than 0
	while ( theNumber > 0 )
	{
		// Get The Next Digit
		theNumber /= 10;

		// There Is One More Digit
		count ++;
	}

	return count;
}

// Time Struct
struct Time
{
	// Variables
	long	hours;
	long	minutes;
	long	seconds;
	long	milliseconds;

	// Constructor
	Time(void){ hours = 0; minutes = 0; seconds = 0; milliseconds = 0; }

	// Operator Overloading =
	Time operator=(const Time& t1)
	{
		this->hours			= t1.hours;
		this->minutes		= t1.minutes;
		this->seconds		= t1.seconds;
		this->milliseconds	= t1.milliseconds;

		return *this;
	}

	// Operator Overloading +
	Time operator+=(const Time& t1)
	{
		this->hours			+= t1.hours;
		this->minutes		+= t1.minutes;
		this->seconds		+= t1.seconds;
		this->milliseconds	+= t1.milliseconds;

		return *this;
	}

	// Operator Overloading +=
	friend Time operator+(const Time& t1, const Time& t2)
	{
		Time temp;
		
		temp.hours			= t1.hours			+ t2.hours;
		temp.minutes		= t1.minutes		+ t2.minutes;
		temp.seconds		= t1.seconds		+ t2.seconds;
		temp.milliseconds	= t1.milliseconds	+ t2.milliseconds;

		return temp;
	}
};